
using Qdb.CS.Internal.Messages;
using Qdb.Ext;
using Qdb.Internal;

namespace Qdb.CS.Internal.Messages
{
	/// <exclude></exclude>
	public class MClassMetadataIdForName : MsgD, IMessageWithResponse
	{
		public Msg ReplyFromServer()
		{
			string name = ReadString();
			ObjectContainerBase stream = Stream();
			Transaction trans = stream.SystemTransaction();
			try
			{
				lock (StreamLock())
				{
					int id = stream.ClassMetadataIdForName(name);
					return Msg.ClassId.GetWriterForInt(trans, id);
				}
			}
			catch (QdbException)
			{
			}
			// TODO: send the exception to the client
			return Msg.Failed;
		}
	}
}
